﻿/*------------------------------------------------
// File Description: WorkOrder DataBase Entity
// Author:			 汪亮
// Create Time:		 2020-02-26 02:34:38
//------------------------------------------------*/

using System;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IOA.MES.DataAccess.VModel;

namespace IOA.MES.DataAccess.Entity
{
    /// <summary>
    /// 工单表
    /// </summary>
    [Table(nameof(WorkOrder))]
    public class WorkOrder : BaseEntity
    {
        private string _orderNo = string.Empty;
        private string _workOrderNo = string.Empty;
        private string _remark = string.Empty;
        private string _productCode = string.Empty;
        private string _productName = string.Empty;
        private string _versionDesc = string.Empty;
        private string _workshopCode = string.Empty;
        private string _workshopName = string.Empty;
        private string _erpWorkOrderNo = string.Empty;
        private string _erpRecord = string.Empty;
        private string _cellLevel = string.Empty;
        private string _cellModel = string.Empty;
        private string _innerOrderNo = string.Empty;
        private string _productSpecs = string.Empty;
        private string _contractNo = string.Empty;
        private string _assistUnitCode = string.Empty;
        private string _lineId = string.Empty;
        private string _lineName = string.Empty;
        private string _protocolNo = string.Empty;
        private string _projectName = string.Empty;
        private string _glassType = string.Empty;

        #region Public Property

        ///<Summary>
        /// 订单号
        ///</Summary>
        public string OrderNo
        {
            get { return string.IsNullOrWhiteSpace(_orderNo) ? string.Empty : _orderNo; }
            set { _orderNo = value; }
        }

        ///<Summary>
        /// 订单行号
        ///</Summary>
        public int OrderRowNum { get; set; }

        ///<Summary>
        /// 内部单号
        ///</Summary>
        public string InnerOrderNo
        {
            get { return string.IsNullOrWhiteSpace(_innerOrderNo) ? string.Empty : _innerOrderNo; }
            set { _innerOrderNo = value; }
        }

        ///<Summary>
        /// 工单号
        ///</Summary>
        public string WorkOrderNo
        {
            get { return string.IsNullOrWhiteSpace(_workOrderNo) ? string.Empty : _workOrderNo; }
            set { _workOrderNo = value; }
        }

        /// <summary>
        /// 销售合同号
        /// </summary>
        public string ContractNo
        {
            get { return string.IsNullOrWhiteSpace(_contractNo) ? string.Empty : _contractNo; }
            set { _contractNo = value; }
        }

        /// <summary>
        /// 项目名称
        /// </summary>
        public string ProjectName
        {
            get { return string.IsNullOrWhiteSpace(_projectName) ? string.Empty : _projectName; }
            set { _projectName = value; }
        }

        /// <summary>
        /// 协议号
        /// </summary>
        public string ProtocolNo
        {
            get { return string.IsNullOrWhiteSpace(_protocolNo) ? string.Empty : _protocolNo; }
            set { _protocolNo = value; }
        }

        ///<Summary>
        /// 生产订单主表标识
        ///</Summary>
        public int ErpWorkOrderId { get; set; }

        ///<Summary>
        /// ERP生产订单号
        ///</Summary>
        public string ErpWorkOrderNo
        {
            get { return string.IsNullOrWhiteSpace(_erpWorkOrderNo) ? string.Empty : _erpWorkOrderNo; }
            set { _erpWorkOrderNo = value; }
        }

        ///<Summary>
        /// ERP生产订单行号
        ///</Summary>
        public int ErpWorkOrderRowNum { get; set; }

        ///<Summary>
        /// 辅助计量单位编码
        ///</Summary>
        public string AssistUnitCode
        {
            get { return string.IsNullOrWhiteSpace(_assistUnitCode) ? string.Empty : _assistUnitCode; }
            set { _assistUnitCode = value; }
        }

        ///<Summary>
        /// 订单子表ID
        ///</Summary>
        public int ErpOrderChildId { get; set; }

        ///<Summary>
        /// 生产订单子表标识
        ///</Summary>
        public int ErpWorkOrderChildId { get; set; }

        ///<Summary>
        /// 换算率
        ///</Summary>
        public decimal? ConversionRate { get; set; }

        /// <summary>
        /// ERP状态
        /// </summary>
        public int ERPWorkOrderStatus { get; set; }

        ///<Summary>
        /// 下单时间
        ///</Summary>
        public DateTime WorkOrderTime { get; set; }

        ///<Summary>
        /// 车间代码
        ///</Summary>
        public string WorkshopCode
        {
            get { return string.IsNullOrWhiteSpace(_workshopCode) ? string.Empty : _workshopCode; }
            set { _workshopCode = value; }
        }

        ///<Summary>
        /// 车间名称
        ///</Summary>
        public string WorkshopName
        {
            get { return string.IsNullOrWhiteSpace(_workshopName) ? string.Empty : _workshopName; }
            set { _workshopName = value; }
        }

        ///<Summary>
        /// 班次ID
        ///</Summary>
        public int DutyId { get; set; }

        ///<Summary>
        /// 成品编码
        ///</Summary>
        public string ProductCode
        {
            get { return string.IsNullOrWhiteSpace(_productCode) ? string.Empty : _productCode; }
            set { _productCode = value; }
        }

        ///<Summary>
        /// 成品物料名称
        ///</Summary>
        public string ProductName
        {
            get { return string.IsNullOrWhiteSpace(_productName) ? string.Empty : _productName; }
            set { _productName = value; }
        }

        ///<Summary>
        /// 成品物料规格
        ///</Summary>
        public string ProductSpecs
        {
            get { return string.IsNullOrWhiteSpace(_productSpecs) ? string.Empty : _productSpecs; }
            set { _productSpecs = value; }
        }

        ///<Summary>
        /// 生产数量
        ///</Summary>
        public decimal Count { get; set; }

        ///<Summary>
        /// 工单备注
        ///</Summary>
        public string Remark
        {
            get { return string.IsNullOrWhiteSpace(_remark) ? string.Empty : _remark; }
            set { _remark = value; }
        }

        ///<Summary>
        /// 工单状态
        ///</Summary>
        public Enum.ProduceStatus Status { get; set; }

        /// <summary>
        /// 开工日期
        /// </summary>
        public DateTime? StartDate { get; set; }

        /// <summary>
        /// 完工日期
        /// </summary>
        public DateTime? EndDate { get; set; }

        /// <summary>
        /// 版本号
        /// </summary>
        public int? Version { get; set; }

        /// <summary>
        /// 版本说明
        /// </summary>
        public string VersionDesc
        {
            get { return string.IsNullOrWhiteSpace(_versionDesc) ? string.Empty : _versionDesc; }
            set { _versionDesc = value; }
        }

        /// <summary>
        /// 部门名称
        /// </summary>
        public string ErpRecord
        {
            get { return string.IsNullOrWhiteSpace(_erpRecord) ? string.Empty : _erpRecord; }
            set { _erpRecord = value; }
        }

        /// <summary>
        /// ERP审核时间
        /// </summary>
        public DateTime? ReviewTime { get; set; }

        /// <summary>
        /// ERP修改时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }

        /// <summary>
        /// 电池片数量
        /// </summary>
        public int? CellQuantity { get; set; }

        /// <summary>
        /// 电池等级
        /// </summary>
        public string CellLevel
        {
            get { return string.IsNullOrWhiteSpace(_cellLevel) ? string.Empty : _cellLevel; }
            set { _cellLevel = value; }
        }

        /// <summary>
        /// 电池型号
        /// </summary>
        public string CellModel
        {
            get { return string.IsNullOrWhiteSpace(_cellModel) ? string.Empty : _cellModel; }
            set { _cellModel = value; }
        }

        /// <summary>
        /// 单片功率
        /// </summary>
        public decimal? SingleCellPower { get; set; }

        /// <summary>
        /// 电池效率
        /// </summary>
        public decimal? CellEfficiencyMin { get; set; }

        /// <summary>
        /// 电池效率
        /// </summary>
        public decimal? CellEfficiencyMax { get; set; }

        /// <summary>
        /// 产线ID
        /// </summary>
        public string LineId
        {
            get { return string.IsNullOrWhiteSpace(_lineId) ? string.Empty : _lineId; }
            set { _lineId = value; }
        }

        /// <summary>
        /// 产线名称
        /// </summary>
        public string LineName
        {
            get { return string.IsNullOrWhiteSpace(_lineName) ? string.Empty : _lineName; }
            set { _lineName = value; }
        }

        /// <summary>
        /// 玻璃类型
        /// </summary>
        public string GlassType
        {
            get { return string.IsNullOrWhiteSpace(_glassType) ? string.Empty : _glassType; }
            set { _glassType = value; }
        }
        #endregion
    }

    public partial class MESContext
    {
        /// <summary>
        /// 工单表
        /// </summary>
        public virtual DbSet<WorkOrder> WorkOrders { get; set; }
    }
}
